//
//  TitleOfDayTableViewCell.m
//  DuckAndDoc
//
//  Created by 蓝水软件 on 2017/6/1.
//  Copyright © 2017年 苏州蓝水有限公司. All rights reserved.
//

#import "TitleOfDayTableViewCell.h"
@interface TitleOfDayTableViewCell()
@property (nonatomic,strong) UILabel *dateLabel;    //日期
@property (nonatomic,strong) UILabel *allCountNum;  //总任务数
@property (nonatomic,strong) UILabel *unfinishedNum;    //未完成任务数
@end

@implementation TitleOfDayTableViewCell

- (void)awakeFromNib {
    [super awakeFromNib];
}

- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
    [super setSelected:selected animated:animated];
}

- (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier{
    if ([super initWithStyle:style reuseIdentifier:reuseIdentifier]) {
        [self.contentView addSubview:self.dateLabel];
        [self.dateLabel mas_makeConstraints:^(MASConstraintMaker *make) {
            make.left.mas_equalTo(32);
            make.right.mas_equalTo(-100);
            make.centerY.equalTo(self);
            make.height.mas_equalTo(30);
        }];
        
        [self.contentView addSubview:self.unfinishedNum];
        self.unfinishedNum.backgroundColor = [UIColor flatOrangeColorDark];
        self.unfinishedNum.textAlignment = NSTextAlignmentCenter;
        self.unfinishedNum.font = FONT(10);
        self.unfinishedNum.layer.cornerRadius = 10;
        self.unfinishedNum.layer.masksToBounds = YES;
        self.unfinishedNum.textColor = QXWhiteColor;
        [self.unfinishedNum mas_makeConstraints:^(MASConstraintMaker *make) {
            make.right.mas_equalTo(10);
            make.width.mas_equalTo(40);
            make.height.mas_equalTo(20);
            make.centerY.equalTo(self);
        }];
    }
    return self;
}

+ (instancetype)cellWithTable:(UITableView *)table{
    static NSString *myIdentifier = @"myIdentifier";
    TitleOfDayTableViewCell *cell = [table dequeueReusableCellWithIdentifier:myIdentifier];
    if (cell == nil) {
        cell = [[TitleOfDayTableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:myIdentifier];
    }
    return cell;
}

- (instancetype)cellWithModel:(workNoteDaymodel *)model{
    self.dateLabel.text = model.date;
    self.allCountNum.text = model.workNoteNum;
    self.unfinishedNum.text = model.unfinishedNum;
    if ([model.unfinishedNum integerValue] > 0) {
        self.unfinishedNum.hidden = NO;
    }else{
        self.unfinishedNum.hidden = YES;
    }
    return self;
}

#pragma mark -- lazy load
- (UILabel *)dateLabel{
    if (_dateLabel == nil) {
        _dateLabel = [UILabel new];
    }
    return _dateLabel;
}

- (UILabel *)allCountNum{
    if (_allCountNum == nil) {
        _allCountNum = [UILabel new];
    }
    return _allCountNum;
}

- (UILabel *)unfinishedNum{
    if (_unfinishedNum == nil) {
        _unfinishedNum = [UILabel new];
    }
    return _unfinishedNum;
}

@end
